

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class CustomerDao {
	SessionFactory factory;
	
	public List<TblCustomers> getCustomers(){
		try{
	         factory = new Configuration().configure().buildSessionFactory();
	      }catch (Throwable ex) { 
	         System.err.println("Failed to create sessionFactory object." + ex);
	         throw new ExceptionInInitializerError(ex); 
	      }
		Session session = factory.openSession();
        org.hibernate.Transaction tx = null;
        List<TblCustomers> list = null;
        try
        {
            tx = session.beginTransaction();
            Query q = session.createQuery("from TblCustomers as blCustomers");
            list = (List<TblCustomers>) q.list();
            tx.commit();
        }
        catch ( Exception e )
        {
            if ( tx != null )
            {
                tx.rollback();
            }
            System.out.println("ERROR: AccountDao.getAccounts() -> Exception : "+e.getMessage());
            e.printStackTrace();
        }
        finally
        {
            session.close();
        }
        return list;
	}
	
	public TblCustomers validateCustomer(String name, String password){
		return null;
	}
}
